package com.boot.unity.api.modules.training.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.boot.unity.api.modules.training.entity.ChargeStandard;
import org.springframework.web.bind.annotation.PathVariable;

@Mapper
public interface ChargeStandardDao {

    @Select("select * from training_charge_standard t where t.id = #{id}")
    ChargeStandard getById(Long id);

    @Delete("delete from training_charge_standard where id = #{id}")
    int delete(Long id);

    int update(ChargeStandard chargeStandard);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into training_charge_standard(inscode, seq, vehicletype, trainningmode, subject, trainningtime, chargemode, paymode, service, price, classcurr, uptime, createTime, updateTime) values(#{inscode}, #{seq}, #{vehicletype}, #{trainningmode}, #{subject}, #{trainningtime}, #{chargemode}, #{paymode}, #{service}, #{price}, #{classcurr}, #{uptime}, now(), now())")
    int save(ChargeStandard chargeStandard);
    
    int count(@Param("params") Map<String, Object> params);

    List<ChargeStandard> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);

    @Select("select * from training_charge_standard where inscode = #{inscode} and seq = #{inscode} limit 1")
    ChargeStandard getByIncodeAndSeq(String inscode, Integer seq);

    int updateByInscodeAndSeq(ChargeStandard chargeStandard);

    @Delete("delete from training_charge_standard where inscode = #{inscode} and seq = #{seq}")
    int deleteByInscodeAndSeq(@Param("inscode") String inscode, @Param("seq") Integer seq);
}
